//
//  User.m
//  MM
//
//  Created by 郑渊文 on 5/21/15.
//  Copyright (c) 2015 王晨辉. All rights reserved.
//

#import "UserDAL.h"
#import "AFHTTPRequestOperationManager.h"
#import "AFNetworking.h"
#import "NSDictionary+JsonString.h"
#import "NSString+DictionaryValue.h"
#import "SSKeychain.h"

@implementation UserDAL


+ (AFHTTPRequestOperation *)getUser:(NSDictionary *)paramDic
                            success:(void (^)(UserModel *user))success
                             failed:(void (^)(NSError *error))failed{
//    ////NSLog(@"paramDic%@",paramDic);
    //直接发送json给服务器端   对应[AFJSONRequestSerializer serializer];
    NSDictionary *param = paramDic;
    
    //将请求参数转换为json后放入key为jsonString的字典中发送请求    对应[AFHTTPRequestSerializer serializer];
    // NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    //[parameters setObject:[param dictionaryToJson] forKey:@"jsonString"];
    
    
    return [[APIClient sharedJsonClient] POST:kNetPath_Code_Login parameters:param success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSString *cachePath = @"Library/Caches/MyCache";
        [responseObject writeToFile:cachePath atomically:YES];
        //NSLog(@"返回的值是denglu%@",responseObject);
        NSInteger responseCode = [responseObject[@"resultCode"] integerValue];
        if (responseCode == 0) {
            if (success) {
                UserModel *user =  [[UserModel alloc] initWithDictionary:responseObject error:nil];
                ////NSLog(@"user的值是什么%@",user);
                //              UserModel *user =  [[UserModel alloc] initWithDictionary:responseObject error:nil];
                success(user);
            }
        }
        else if (responseCode !=0)
        {
            NSString *str = responseObject[@"msg"];
            //NSLog(@"=======%@",str);
            if (failed) {
                failed(str);
            }
        }
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        failed(error);
        //NSLog(@"错了错了");

    }];
}



//获取验证码
+ (AFHTTPRequestOperation *)getCheckNum:(NSDictionary *)paramDic
                              withBlock:(void (^)(NSString *checkNum, NSError *error))block{
    
    return [[APIClient sharedJsonClient] POST:kNetPath_Code_Check parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        ////NSLog(@"返回的值是%@",responseObject);
        NSInteger resultCode = [responseObject[@"code"] integerValue];
        NSString *authenticationCode =responseObject[@"authenticationCode"];
        if (resultCode==0) {
            block(authenticationCode,nil);
        }
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
};

//注册
+ (AFHTTPRequestOperation *)registerWithParams:(NSDictionary *)paramDic
                                     withBlock:(void (^)(NSDictionary *data, NSError *error))block{
    
    return [[APIClient sharedJsonClient] POST:kNetPath_Code_Rigister parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
//        NSArray *data = responseObject;
        ////NSLog(@"返回的值是%@",responseObject);
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
};

//获取首页图片
+ (AFHTTPRequestOperation *)getFirstImgWithParams:(NSDictionary *)paramDic
                                        withBlock:(void (^)(NSArray *data, NSError *error))block{
    
    return [[APIClient sharedJsonClient] POST:kNetPath_Code_FirstPageInfo parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSArray *data = responseObject[@"dataList"];
        //NSLog(@"返回的值是主页的%@",responseObject);
        block(data,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
};

//家园系统
+ (AFHTTPRequestOperation *)getHomeDataWithParams:(NSDictionary *)paramDic
                                        withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_Code_homeCollection parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
//        NSArray *data = responseObject[@"dataList"];
//        ////NSLog(@"返回的值是家园%@",responseObject);
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}


//出发
+ (AFHTTPRequestOperation *)getOutDoorWithParams:(NSDictionary *)paramDic
                                       withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    
    return [[APIClient sharedJsonClient] POST:kNetPath_outDoorContent parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
//        NSArray *data = responseObject[@"dataList"];
        //NSLog(@"返回的值是%@",responseObject);
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

//活动类别
+ (AFHTTPRequestOperation *)getOutDoorActivitiesWithParams:(NSDictionary *)paramDic
                                                 withBlock:(void (^)(NSArray *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_outDoorActivities parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
                NSArray *data = responseObject[@"activityList"];
        //NSLog(@"返回的值是1%@",responseObject);
        block(data,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
    
}

//活动报名接口
+ (AFHTTPRequestOperation *)getActivityJoinedInfoWithParams:(NSDictionary *)paramDic
                                                  withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_ActivityJoinedInfo parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
    
}

//发表活动评论接口
+ (AFHTTPRequestOperation *)getActivityCommentsWithParams:(NSDictionary *)paramDic
                                                withBlock:(void (^)(NSArray *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_ActivityComments parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
    
    
}

//参与活动接口
+ (AFHTTPRequestOperation *)getActivityJoineWithParams:(NSDictionary *)paramDic
                                             withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_ActivityJoine parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        //NSLog(@"返回的值是%@",responseObject);
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
    
}

//课程支付接口
+ (AFHTTPRequestOperation *)getClassesPaymentWithParams:(NSDictionary *)paramDic
                                              withBlock:(void (^)(NSArray *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_ClassesPayment parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

//消息详情
+ (AFHTTPRequestOperation *)getMessageDetailsWithParams:(NSDictionary *)paramDic
                                              withBlock:(void (^)(NSArray *data, NSError *error))block
{
    
    return [[APIClient sharedJsonClient] POST:kNetPath_MessageDetails parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
    
}

//消息中心
+ (AFHTTPRequestOperation *)getMessageCenterWithParams:(NSDictionary *)paramDic
                                             withBlock:(void (^)(NSArray *data, NSError *error))block
{
    
    return [[APIClient sharedJsonClient] POST:kNetPath_MessageCenter parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
    
}
// 添加宝宝
+ (AFHTTPRequestOperation *)addBabyWithParams:(NSDictionary *)paramDic
                                    withBlock:(void (^)(NSArray *data, NSError *error))block
{
    
    return [[APIClient sharedJsonClient] POST:kNetPath_AddBaby parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
    
}
// 宝宝园内点滴
+ (AFHTTPRequestOperation *)getBabyHistoryWithParams:(NSDictionary *)paramDic
                                           withBlock:(void (^)(NSArray *data, NSError *error))block
{
    
    return [[APIClient sharedJsonClient] POST:kNetPath_BabyHistory parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
    
}
//  孩子成长报告
+ (AFHTTPRequestOperation *)getBabyReportDetailsWithParams:(NSDictionary *)paramDic
                                                 withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    
    return [[APIClient sharedJsonClient] POST:kNetPath_BabyReportDetails parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
    
}

//活动详情
+ (AFHTTPRequestOperation *)getOutDoorActivityDetailsWithParams:(NSDictionary *)paramDic
                                                      withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_OutDoorActivityDetails parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        //NSLog(@"返回的值是%@",responseObject);
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
    
}
//预约课程
+ (AFHTTPRequestOperation *)getAllClassesWithParams:(NSDictionary *)paramDic
                                        withBlock:(void (^)(NSArray *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_GetAllClasses parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
                NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        block(data,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

//早教指导师预约&&支付
+ (AFHTTPRequestOperation *)getteacherAppointmentPaymentParams:(NSDictionary *)paramDic
                                                   withBlock:(void (^)(NSArray *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_GetTeacherIdleTime parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

//导师空闲时间查询
+ (AFHTTPRequestOperation *)getTeacherIdleTimeParams:(NSDictionary *)paramDic
                                         withBlock:(void (^)(NSArray *data, NSError *error))block
{
    
    return [[APIClient sharedJsonClient] POST:kNetPath_TeacherAppointmentPayment parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];

}

//早教指导老师预约
+ (AFHTTPRequestOperation *)getTeachersParams:(NSDictionary *)paramDic
                                  withBlock:(void (^)(NSArray *data, NSError *error))block
{
       return [[APIClient sharedJsonClient] POST:kNetPath_GetTeachers parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
                NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        block(data,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}


//早教指导老师预约
+ (AFHTTPRequestOperation *)getPreschoolEducationInfoParams:(NSDictionary *)paramDic
                                                withBlock:(void (^)(NSArray *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_Code_EducationInfo parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
                NSArray *data = responseObject[@"dataList"];
//        ////NSLog(@"返回的值是%@",responseObject);
        block(data,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

//早教指导老师详情
+ (AFHTTPRequestOperation *)getTowPreschoolEducationInfoParams:(NSDictionary *)paramDic
                                                  withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_Code_EducationInfo parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
//        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

+ (AFHTTPRequestOperation *)getPreschoolEducationInfoParamsTwo:(NSDictionary *)paramDic
                                                  withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_Code_EducationInfo parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
//        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}




//同城解读
+ (AFHTTPRequestOperation *)getEvaluationDetailItemsParams:(NSDictionary *)paramDic
                                               withBlock:(void (^)(NSArray *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_EvaluationDetailItems parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
                NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        block(data,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
            

            
        }
    }];
}
//测评报告展示
+ (AFHTTPRequestOperation *)getevaluationResultsShownParams:(NSDictionary *)paramDic
                                                withBlock:(void (^)(NSArray *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_EvaluationResultsShown parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

//测题回顾
+ (AFHTTPRequestOperation *)getEvaluationResultsReviewParams:(NSDictionary *)paramDic
                                                 withBlock:(void (^)(NSArray *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_EvaluationResultsReview parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];

}

//测评结果提交
+ (AFHTTPRequestOperation *)getevaluationResultsSubmitParams:(NSDictionary *)paramDic
                                                 withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    
    return [[APIClient sharedJsonClient] POST:kNetPath_EvaluationResultsSubmit parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
            
            ////NSLog(@"%@",operation);
            
            
        }
    }];

}
//测评题目
+ (AFHTTPRequestOperation *)startEvaluationParams:(NSDictionary *)paramDic
                                      withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    
    return [[APIClient sharedJsonClient] POST:kNetPath_StartEvaluation parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
//        ////NSLog(@"返回的值是%@",responseObject);
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

//测评信息
+ (AFHTTPRequestOperation *)getCharacterEvaluatingParams:(NSDictionary *)paramDic
                                             withBlock:(void (^)(NSArray *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_CharacterEvaluating parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

//地址接口
+ (AFHTTPRequestOperation *)getAreasParams:(NSDictionary *)paramDic
                               withBlock:(void (^)(NSArray *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_GetAreas parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        NSArray *array = responseObject[@"dataList"];
        block(array,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

//消息中心
+ (AFHTTPRequestOperation *)getMessageCenterParams:(NSDictionary *)paramDic
                                         withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    
    return [[APIClient sharedJsonClient] POST:kNetPath_MessageCenter  parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        //        NSArray *array = responseObject[@"dataList"];
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
    
}

//消息详情
+ (AFHTTPRequestOperation *)getMessageDetailsParams:(NSDictionary *)paramDic
                                          withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_MessageDetails  parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        //        NSArray *array = responseObject[@"dataList"];
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
    
}

//获取早教状态
+ (AFHTTPRequestOperation *)getTeachstatusParams:(NSDictionary *)paramDic
                                       withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_GetTeachstatus  parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        //        NSArray *array = responseObject[@"dataList"];
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

//添加宝宝
+ (AFHTTPRequestOperation *)getAddBabyParams:(NSDictionary *)paramDic
                                   withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_AddBaby  parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        //        NSArray *array = responseObject[@"dataList"];
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
    
}

//等待支付
+ (AFHTTPRequestOperation *)getWaitForPayParams:(NSDictionary *)paramDic
                                      withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_WaitForPay  parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        //        NSArray *array = responseObject[@"dataList"];
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
    
}


//上课中
+ (AFHTTPRequestOperation *)getInteachingParams:(NSDictionary *)paramDic
                                      withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_Inteaching  parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        //        NSArray *array = responseObject[@"dataList"];
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
    
}

//上课详情
+ (AFHTTPRequestOperation *)getClassdetailParams:(NSDictionary *)paramDic
                                       withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_Classdetail  parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        //        NSArray *array = responseObject[@"dataList"];
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}
//上课总结
+ (AFHTTPRequestOperation *)getClasssummaryParams:(NSDictionary *)paramDic
                                        withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_Classsummary  parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        //        NSArray *array = responseObject[@"dataList"];
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
    
}

+ (AFHTTPRequestOperation *)getClasssuggestParams:(NSDictionary *)paramDic
                                        withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_Classsuggest  parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回的值是%@",responseObject);
        //        NSArray *array = responseObject[@"dataList"];
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}


//家园统合
+ (AFHTTPRequestOperation *)getHomeCollectionParams:(NSDictionary *)paramDic
                                          withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_HomeCollection  parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        
        ////NSLog(@"返回的值是%@",responseObject);
        //        NSArray *array = responseObject[@"dataList"];
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}
//宝宝园内点滴
+ (AFHTTPRequestOperation *)getBabyHistoryParams:(NSDictionary *)paramDic
                                       withBlock:(void (^)(NSArray *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_BabyHistory  parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSArray *data = responseObject[@"dataList"];
        ////NSLog(@"返回%@",responseObject[@"msg"]);
        ////NSLog(@"返回的值是%@",responseObject);
        //        NSArray *array = responseObject[@"dataList"];
        block(data,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

//户外亲子
+ (AFHTTPRequestOperation *)getHomePaternityActivityParams:(NSDictionary *)paramDic
                                               withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_HomePaternityActivity  parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        
        ////NSLog(@"返回的值是%@",responseObject);
        //        NSArray *array = responseObject[@"dataList"];
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];

}


//查看评价
+ (AFHTTPRequestOperation *)getReadEvaluationParams:(NSDictionary *)paramDic
                                        withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_ReadEvaluation  parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        
        ////NSLog(@"返回的值是%@",responseObject);
        //        NSArray *array = responseObject[@"dataList"];
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];

}

//意见反馈
+ (AFHTTPRequestOperation *)getAppsuggestionParams:(NSDictionary *)paramDic
                                       withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_Appsuggestion  parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        
        ////NSLog(@"返回的值是%@",responseObject);
        //        NSArray *array = responseObject[@"dataList"];
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

//我的同城解读
+ (AFHTTPRequestOperation *)getMyEvaluationDetailItemsParams:(NSDictionary *)paramDic
                                                 withBlock:(void (^)(NSArray *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_MyEvaluationDetailItems  parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
                NSArray *data = responseObject[@"dataList"];
        
        ////NSLog(@"返回的值是%@",responseObject);
        //        NSArray *array = responseObject[@"dataList"];
        block(data,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

///答案提交
+ (AFHTTPRequestOperation *)getEvaluationResultsSubmitParams:(NSDictionary *)paramDic
                                                 withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_EvaluationResultsSubmit  parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //        NSArray *data = responseObject[@"dataList"];
        
        ////NSLog(@"返回的值是%@",responseObject);
        //        NSArray *array = responseObject[@"dataList"];
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];

}

+ (AFHTTPRequestOperation *)getParentReportParams:(NSDictionary *)paramDic
                                                   withBlock:(void (^)(NSArray *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_ParentReport    parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        ////NSLog(@"返回的值是%@",responseObject);
        NSArray *array = responseObject[@"dataList"];
        block(array,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
    
}


//评测报告
+ (AFHTTPRequestOperation *)getResetPasswordParams:(NSDictionary *)paramDic
                                         withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_ResetPassword    parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        ////NSLog(@"返回的值是%@",responseObject);
        //        NSArray *array = responseObject[@"dataList"];
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}
//宝宝成长报告
+ (AFHTTPRequestOperation *)getBabyGrewUpReportParams:(NSDictionary *)paramDic
                                          withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_BabyGrewUpReport    parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        ////NSLog(@"返回的值是%@",responseObject);
        //        NSArray *array = responseObject[@"dataList"];
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];

}

//删除宝宝
+ (AFHTTPRequestOperation *)getDeletebabyParams:(NSDictionary *)paramDic
                                    withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_deletebaby    parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
//        //NSLog(@"返回的值是%@",responseObject);
        //        NSArray *array = responseObject[@"dataList"];
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

//课程报名
+ (AFHTTPRequestOperation *)classAppointmentParams:(NSDictionary *)paramDic
                                      withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_classAppointment    parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        ////NSLog(@"返回的值是%@",responseObject);
        //        NSArray *array = responseObject[@"dataList"];
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

//获取宝宝
+ (AFHTTPRequestOperation *)getBabysParams:(NSDictionary *)paramDic
                                 withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_GetBabys    parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        ////NSLog(@"返回的值是%@",responseObject);
        //        NSArray *array = responseObject[@"dataList"];
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

//预约老师
+ (AFHTTPRequestOperation *)teacherAppointmentParams:(NSDictionary *)paramDic
                                 withBlock:(void (^)(NSDictionary *data, NSError *error))block
{
    return [[APIClient sharedJsonClient] POST:kNetPath_teacherAppointment    parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        ////NSLog(@"返回的值是%@",responseObject);
        //        NSArray *array = responseObject[@"dataList"];
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
}

//支付宝
+ (AFHTTPRequestOperation *)alipayCenterParams:(NSDictionary *)paramDic
                                     withBlock:(void (^)(NSDictionary *data, NSError *error))block{
    
    return [[APIClient sharedJsonClient] POST:kNetPath_alipayConfig    parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        ////NSLog(@"返回的值是%@",responseObject);
        //        NSArray *array = responseObject[@"dataList"];
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
    
}




//测评报告详情
+ (AFHTTPRequestOperation *)evaluationResultsDetailsParams:(NSDictionary *)paramDic
                                                 withBlock:(void (^)(NSDictionary *data, NSError *error))block{
    
    return [[APIClient sharedJsonClient] POST:kNetPath_evaluationResultsDetails    parameters:paramDic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        ////NSLog(@"返回的值是%@",responseObject);
        //        NSArray *array = responseObject[@"dataList"];
        block(responseObject,nil);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        if (block) {
            block(nil, error);
        }
    }];
    
    
}

//注销
+ (void)logoutAccount{
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    [userDefaults removeObjectForKey:KEY_USER_NAME];
    [userDefaults synchronize];
}

//获取userdefault用户名 和钥匙串中密码
+ (void)getAccount:(void (^)(NSString *username,NSString *password))block{
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    NSString *username = [userDefaults objectForKey:KEY_USER_NAME];
    NSString *password = [SSKeychain passwordForService:KEY_KEYCHAIN_SERVICE account:username];
    block(username?:@"",password?:@"");
}
//存储用户名userdefault ,密码到钥匙串
+ (void)saveAccount:(NSString *)name andPassword:(NSString *)password {
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    [userDefaults setObject:name forKey:KEY_USER_NAME];
    [userDefaults synchronize];
    [SSKeychain setPassword:password forService:KEY_KEYCHAIN_SERVICE account:name];
}

@end
